home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17523 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news.eng.convex.com!arco!usenet
  3. From: Brian Leach <lasbfl@aai.arco.com>
  4. Subject: Re: new with multidimensional arrays
  5. X-Nntp-Posting-Host: 136.226.116.1
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <3172BAEA.5555@aai.arco.com>
  8. Sender: usenet@news.arco.com
  9. Content-Transfer-Encoding: 7bit
  10. Organization: ARCO Alaska Inc.
  11. References: <3169B9C3.2A10@MIT.EDU> <316EC85C.1A21@aai.arco.com>
  12. Mime-Version: 1.0
  13. Date: Mon, 15 Apr 1996 21:08:58 GMT
  14. X-Mailer: Mozilla 2.0 (X11; I; HP-UX A.09.05 9000/755)
  15.  
  16. Brian Leach wrote:
  17. > Darrel K Robertson wrote:
  18. > >
  19. > > Hi, I wonder if anyone can help me. I want to use "new" to create a
  20. > > multidimensional array, but don't know how. So far I have:
  21. > > complex *grid;
  22. > > scanf("%d %d", &nc, &nr);
  23. > > grid = new complex[nc][nr];
  24. > >
  25. > > Unfortunately this won't work. Any info would be much appreciated.
  26. > > Darrel.
  27. > All but the left-most dimension of multiple dimensional arrays must be
  28. > known at compile time. This is because C and C++ internally generate
  29. > arrays of arrays, for proper indexing, the length has to be known when
  30. > the program compiles. You get around this by using the STL vector
  31. > classes.
  32. > What you want to do is illegal.
  33. > -Brian :-)
  34. > lasbfl@aai.arco.com
  35. Once again, I have made an error, all dimensions must be known
  36. at compile time. However, when passing the array to a function,
  37. the left-most dimension need not be known.
  38.  
  39. -Brian :-(
  40.